package com.yangfan.cloudalibaba.service.impl;

import com.yangfan.cloudalibaba.dao.AccountDao;
import com.yangfan.cloudalibaba.service.AccountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;

@Slf4j
@Service
public class AccountServiceImpl implements AccountService {

    @Resource
    private AccountDao accountDao;

    @Override
    public void decrease(Long userId, BigDecimal money) {

        log.info(" ------------------> 开始扣减余额");

        accountDao.decrease(userId,money);

        //人工报错 如果 钱是 1000 就人造报错
        if(money.longValue() == 1000){
            int i = 10/0;
        }

        log.info(" ------------------> 结束扣减余额");
    }


}
